Skip to content

PR Title: Fixes #27345: Add usage count column to Classification tags table#27460

Open
karthik120710 wants to merge 6 commits intoopen-metadata:mainfrom
karthik120710:issue#27345
Open

PR Title: Fixes #27345: Add usage count column to Classification tags table#27460
karthik120710 wants to merge 6 commits intoopen-metadata:mainfrom
karthik120710:issue#27345

Conversation

@karthik120710
Copy link
Copy Markdown

@karthik120710 karthik120710 commented Apr 17, 2026

Fixes #27345

Added a new "Assets" (usage count) column to the common columns in ClassificationUtils.tsx. This column displays the usageCount field for
each tag, showing how many assets are associated with a given classification tag. The column falls back to the NO_DATA_PLACEHOLDER when the
value is null/undefined.

I worked on this because the tags table was missing visibility into how many assets reference each tag, which is useful for understanding
tag adoption and cleaning up unused tags.


Type of change:

  • Improvement

Checklist:

Improvement checklist:

  • I have added tests around the new logic.
  • For connector/ingestion changes: I updated the documentation.

Screenshot/Preview: (please add a screenshot of the tags table showing the new "Assets" column)


Files changed:

  • openmetadata-ui/src/main/resources/ui/src/utils/ClassificationUtils.tsx — Added usageCount column rendering in getCommonColumns()

image -
image


Summary by Gitar

  • Database security:
    • Refactored buildUsageCountQuery in TagRepository to use parameterized SQL queries, effectively mitigating potential SQL injection risks.
  • Testing:
    • Updated TagRepositoryUnitTest to validate the new parameter binding structure, ensuring correct usage of hashes and named parameters instead of literal string concatenation.

This will update automatically on new commits.

@karthik120710 karthik120710 requested a review from a team as a code owner April 17, 2026 08:40
@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@chirag-madlani
Copy link
Copy Markdown
Collaborator

Hi @karthik120710, thanks for the PR. For the UI changes, can you update the screenshot in the PR description for easy review?

Also, your PR is missing tests, which is required.

@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@karthik120710
Copy link
Copy Markdown
Author

@chirag-madlani can u review my pr.

@chirag-madlani
Copy link
Copy Markdown
Collaborator

Hi @karthik120710 I gone throught this and it seems the param usageCount isn't pulling the right count, it seems always 0 so if we merge above changes still user won't be able to see the correct count.

Can you ensure that count refalcts actual count and not just the adding the param?

@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@karthik120710
Copy link
Copy Markdown
Author

@chirag-madlani i updated the changes in backend and added some unit test.

@chirag-madlani
Copy link
Copy Markdown
Collaborator

@karthik120710 CI is failing after the commit please check those

karthik120710 and others added 2 commits April 20, 2026 13:50
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

…t SQL injection

Replace string formatting with JDBI named parameters (:tagFQN_i, :hash_i, :source).
Introduces UsageCountQuery record to carry template + bindings, keeping the method
testable. Tests updated to assert on bindings map rather than inline SQL literals.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Apr 20, 2026

Code Review ✅ Approved 1 resolved / 1 findings

Adds a usage count column to the classification tags table while addressing security concerns by replacing string-formatted SQL with parameterized queries. No further issues found.

✅ 1 resolved
Security: SQL built via string formatting instead of parameterized queries

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java:714-728
The buildUsageCountQuery method constructs SQL using String.formatted() with escapedFQN (only single-quote escaping). While fqnHash is safe (hex-encoded MD5), the escapedFQN value derived from Tag::getFullyQualifiedName() uses minimal escaping. Since FQNs are system-controlled and validated on creation, this is low risk in practice, but parameterized queries would be more robust.

This is a pre-existing pattern that the PR inherited — the diff only refactored the method extraction and hash fix — so this is noted as minor rather than blocking.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display Tag Usage Statistics for All Tags in Classification View

2 participants